<!--  -->
<template>
    <div>
    <nav class="ui inverted attached segment m-pad-tb-null m-opacity m-shadow-small">
        <div class="ui container">
            <div class="ui inverted secondary  menu stackable m-nav">
                <h1 class="ui teal header item ">Blog</h1>
                <router-link class="m-item item m-mobile-hide" to="/index"><i class="home icon"></i>首页</router-link>
                <router-link class="m-item item m-mobile-hide" to="/types"><i class="idea icon"></i>分类</router-link>
                <router-link class="m-item item m-mobile-hide" to="/archives"><i class="history icon"></i>归档</router-link>
                <router-link class="m-item item m-mobile-hide" to="/anime"><i class="thumbs up icon"></i>番剧</router-link>
                <router-link class="m-item item m-mobile-hide" to="/about"><i class="info icon"></i>关于我</router-link>
                <router-link class="m-item item m-mobile-hide" to="/admin" v-if="admin"><i class="block layout icon"></i>管理后台</router-link>
                <div class="m-item right item  m-mobile-hide">
                    <div class="ui icon inverted transparent input">
                        <input type="text" placeholder="搜索..." v-model="keyword" @keyup.enter="search">
                        <i class="search icon link" @click="search"></i>
                    </div>
                </div>
            </div>
        </div>
    </nav>
    </div>
</template>

<script>
export default {
    name:'MyNav',
    data () {
        return {
            admin:localStorage.getItem('user') ? true : false,
            keyword:""
        };
    },
    methods:{
        search(){
            var _this = this
            _this.axios.get("/searchShowBlogs",{
                params:{
                    keyword:_this.keyword
                }
            }).then(res=>{
                $(window).scrollTo(0);
                _this.$store.commit("setBlogs",res.data.pageInfo)
                _this.$store.commit("setKeyword",this.keyword)
                if(this.$route.path != "/search"){
                    this.$router.push({path:"/search"})
                }
            }).catch(e=>{
                console.log(e)
            })
        }
    },
}

</script>
<style lang='scss' scoped>
</style>